<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Released under the MIT License.
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------

namespace app\home\controller;

use cmf\controller\HomeBaseController;
class AController extends HomeBaseController
{

	/**
    *
    *访问短链
    *
    **/
    public function shortUrlRedirectUrl()
    {
        $data = $this->request->param();//课程ID

        $slink_id = $data['slink_id'];
        if(empty($slink_id))
        {
            $this->error('ID不存在，无法操作');
        }

        $Model = new \app\home\model\CourseSlinkModel();
    
        //查找短链
        $where = [
            ['vcode', '=', $slink_id],
        ];
        $con_info = $Model->getMemberShortLink($where);
        if(empty($con_info))
        {   
            //没有对应数据，调到首页
            $this->redirect('/');
        }else{
            //开始重定向
            $this->redirect("{$con_info['url']}");
        }
    }

}